package com.ityun.ogapp.dao

import androidx.room.*
import com.ityun.ogapp.data.ContactBean
import kotlinx.coroutines.flow.Flow

@Dao
interface ContactDao {

    @Query("SELECT * FROM contacts")
    fun getAllContacts(): Flow<List<ContactBean>>

    @Query("SELECT * FROM contacts WHERE id = :id")
    suspend fun getContactById(id: Long): ContactBean?

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    suspend fun insert(contact: ContactBean): Long

    @Update
    suspend fun update(contact: ContactBean)

    @Delete
    suspend fun delete(contact: ContactBean)

    @Query("DELETE FROM contacts")
    suspend fun deleteAll()
}
